feat: implement polling fallback for event communication#40
Merged
takaokouji merged 6 commits intomainfrom Jan 11, 2026
Merged
Conversation
- Updated GraphQL schema with recordEventsByNode and getEventsSince - Implemented JS resolvers for polling support - Updated createGroup and joinGroup to handle useWebSocket flag - Added environment variables for polling interval and event TTL - Updated documentation and tests Co-Authored-By: Gemini <noreply@google.com>
… to Lambda - Moved recordEventsByNode from JS pipeline to Ruby Lambda (due to JS limitation) - Implemented RecordEventsUseCase and record_events method in DynamoDBRepository - Renamed Lambda resources to MeshV2LambdaFunction/DataSource for clarity - Added MESH_EVENT_TTL_SECONDS and MESH_POLLING_INTERVAL_SECONDS to Lambda env - Updated request specs to include required useWebSocket argument - Removed unused JS resolver file
…e type - Added createdAt to Node type in schema - Added createdAt to HeartbeatPayload and MemberHeartbeatPayload - Return createdAt in joinGroup, renewHeartbeat, and updateNodeTTL functions - Added createdAt and expiresAt to CreateGroupUseCase in Lambda - Return nextSince correctly in RecordEventsUseCase
- Reverted schema changes for createdAt - Reverted Lambda and JS function changes for createdAt - Retained record_events batch processing improvements
- Fixed missing attributeValues in joinGroupFunction.js - Fixed formatting and indentation in updateNodeTTL.js - Fixed incorrect function name in mesh-v2-stack.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Server-side implementation of polling-based event notification fallback for Mesh v2. Adds
recordEventsByNodemutation andgetEventsSincequery to support environments where WebSocket connections are blocked.Implementation Details
GraphQL Schema Changes
New Types and Fields
RecordEventsPayload: Response type forrecordEventsByNodemutationnextSince: Cursor for nextgetEventsSincecallEvent.cursor: Sort Key (SK) for cursor-based paginationGroup.useWebSocket: Protocol selection flagGroup.pollingIntervalSeconds: Polling interval (when useWebSocket=false)Node.useWebSocket: Inherited from groupNode.pollingIntervalSeconds: Inherited from groupNew Mutations
createGroup: AddeduseWebSocketparameterrecordEventsByNode: Records events to DynamoDB (polling only)New Queries
getEventsSince: Retrieves events since last fetch (cursor-based)Server-side Timestamp Management
IMPORTANT:
recordEventsByNodeuses server-side timestamps, not client-sideevent.firedAt.Reason: 1+ second delay exists from device event firing to
recordEventsByNodecall.Implementation:
Benefits:
sinceparameter ingetEventsSinceCursor-based Pagination
getEventsSinceuses Sort Key (SK) as cursor:Environment Variables
MESH_EVENT_TTL_SECONDS: 10 (events auto-delete after 10 seconds)MESH_POLLING_INTERVAL_SECONDS: 2 (poll every 2 seconds)CDK Stack Changes
recordEventsByNodeandgetEventsSinceresolversuseWebSocketflagTesting
Unit Tests
recordEventsByNodesaves events with server-side timestampsgetEventsSinceretrieves events with cursor paginationcreateGroupacceptsuseWebSocketparameterIntegration Tests
Cost Optimization
Related
🤖 Generated with Claude Code